home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / incoming / jstools-.6v3 / jstools- / jstools-tk3.6v3.0 / lib / jdoc_ui.tcl < prev    next >
Encoding:
Text File  |  1995-02-09  |  4.7 KB  |  136 lines

  1. # jdoc_ui.tcl - gui procedures for jdoc (also bindings)
  2. # Copyright 1992-1994 by Jay Sekora.  All rights reserved, except 
  3. # that this file may be freely redistributed in whole or in part 
  4. # for non-profit, noncommercial use.
  5.  
  6. ##############################################################################
  7. # jdoc:mkmenus - menu bar
  8. ##############################################################################
  9.  
  10. proc jdoc:mkmenus {} {
  11.   frame .menu -borderwidth 2 -relief raised
  12.   
  13.   jdoc:mkmenu:doc
  14.   jdoc:mkmenu:document
  15.   jdoc:mkmenu:sections
  16.   
  17.   pack .menu -in . -side top -fill x
  18.   
  19.   tk_menuBar .menu .menu.doc .menu.document .menu.sections
  20. }
  21.  
  22. ##############################################################################
  23. # jdoc:mkmenu:doc - doc menu
  24. ##############################################################################
  25.  
  26. proc jdoc:mkmenu:doc {} {
  27.   menubutton .menu.doc -text {Doc Viewer} -menu .menu.doc.m
  28.   pack .menu.doc -in .menu -side left
  29.  
  30.   menu .menu.doc.m
  31.   .menu.doc.m add command -label {Help with Doc Viewer} -accelerator {[h]} \
  32.     -command {jdoc:cmd:help}
  33.   .menu.doc.m add command -label {About the Doc Viewer . . .} \
  34.     -command {jdoc:cmd:about}
  35.   .menu.doc.m add command -label {Global Preferences . . .} \
  36.     -accelerator {[G]} \
  37.     -command {j:global_pref_panel}
  38.   .menu.doc.m add command -label {Doc Viewer Preferences . . .} \
  39.     -accelerator {[P]} \
  40.     -command {jdoc:cmd:doc_prefs}
  41.   .menu.doc.m add separator
  42.   .menu.doc.m add command -label {Issue Tcl Command . . .} \
  43.     -accelerator {[T]} -command {j:prompt_tcl}
  44.   .menu.doc.m add command -label {Issue Unix Command . . .} \
  45.     -accelerator {[U]} -command {j:prompt_unix}
  46.   .menu.doc.m add separator
  47.   .menu.doc.m add command -label {Quit} -accelerator {[q]} \
  48.     -command {destroy .}
  49. }
  50.  
  51. ##############################################################################
  52. # jdoc:mkmenu:document - document menu
  53. ##############################################################################
  54.  
  55. proc jdoc:mkmenu:document {} {
  56.   menubutton .menu.document -text {Document} -menu .menu.document.m
  57.   menu .menu.document.m
  58.   .menu.document.m add command -label {Load . . .} \
  59.     -accelerator {[l]} -command {jdoc:cmd:load}
  60.   .menu.document.m add command -label {Save As . . .} \
  61.     -command "j:tc:saveas .t"
  62.   .menu.document.m add command -label {Print} \
  63.     -command "jdoc:cmd:print_postscript"
  64.   .menu.document.m add separator
  65.   .menu.document.m add command -label {Find . . .} -accelerator {[f]} \
  66.     -command "j:find -replace 0 .t"
  67.  
  68.   pack .menu.document -in .menu -side left
  69. }
  70.  
  71. ##############################################################################
  72. # jdoc:mkmenu:sections - sections menu
  73. ##############################################################################
  74.  
  75. proc jdoc:mkmenu:sections {} {
  76.   menubutton .menu.sections -text {Sections} -menu .menu.sections.m
  77.   pack .menu.sections -in .menu -side left
  78.  
  79.   menu .menu.sections.m
  80. }
  81.  
  82. ##############################################################################
  83. # jdoc:mkbuttons - buttons at bottom
  84. ##############################################################################
  85.  
  86. proc jdoc:mkbuttons {} {
  87.   j:buttonbar .b -buttons {
  88.     {done Done {destroy .}}
  89.     {open "Load..." {jdoc:cmd:load}}
  90.     {print "Print" {jdoc:cmd:print_postscript}}
  91.     {find "Find..." {j:find -replace 0 .t}}
  92.   }
  93.   pack .b [j:rule .] -in . -side bottom -fill x
  94. }
  95.  
  96. ##############################################################################
  97. # jdoc:mktext - text widget
  98. ##############################################################################
  99.  
  100. proc jdoc:mktext {} {
  101.   global J_PREFS
  102.   if {[lsearch [array names J_PREFS] {scrollbarside}] == -1} {
  103.     set J_PREFS(scrollbarside) right ;# make sure it's defined
  104.   }
  105.   text .t -yscrollcommand {.s set} \
  106.     -width 70 -height 18 -borderwidth 4 \
  107.     -setgrid true -wrap word
  108.   scrollbar .s -relief flat -command {.t yview}
  109.   pack .s [j:rule .] -in . -side $J_PREFS(scrollbarside) -fill y
  110.   pack .t -in . -side $J_PREFS(scrollbarside) -fill both -expand y
  111.   jdoc:configure_text .t
  112.   
  113.   focus .t
  114.   catch {focus default .t}            ;# caught for Tk 4.0
  115.   tk_bindForTraversal .t
  116. }
  117.  
  118.  
  119. ##############################################################################
  120. # jdoc:mkbindings widgets - text widget command bindings
  121. ##############################################################################
  122.  
  123. proc jdoc:mkbindings { { widgets .t } } {
  124.   foreach w $widgets {
  125.     bind $w <Meta-f> {j:find -replace 0 .t}
  126.     bind $w <Meta-h> {jdoc:cmd:help}
  127.     bind $w <Meta-l> {jdoc:cmd:load}
  128.     bind $w <Meta-q> {jdoc:cmd:quit}
  129.     bind $w <Meta-G> {j:global_pref_panel}
  130.     bind $w <Meta-P> {jdoc:cmd:doc_prefs}
  131.     bind $w <Meta-T> {j:prompt_tcl}
  132.     bind $w <Meta-U> {j:prompt_unix}
  133.   }
  134. }
  135.